package com.duolaibei.business.view.fragment;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.duolaibei.business.R;
import com.duolaibei.business.base.BaseFragment;
import com.duolaibei.business.config.Constant;
import com.duolaibei.business.utils.inject.Inject;
import com.duolaibei.business.view.activity.AccountInfoActivity;
import com.duolaibei.business.view.App;
import com.duolaibei.business.view.activity.ChangeMobileActivity;
import com.duolaibei.business.view.activity.RegistAndForgetActivity;

/**
 * Created by xlm on 2017/10/30 0030
 * 账户信息
 */

public class AccountFragment extends BaseFragment {

    @Inject(R.id.back)
    private RelativeLayout mLayoutBack;
    @Inject(R.id.title)
    private TextView mTextViewTitle;
    @Inject(R.id.mobile_change)
    private RelativeLayout mLayoutMobileChange;
    @Inject(R.id.password_change)
    private RelativeLayout mLayoutPasswordChange;
    @Inject(R.id.merchant_info)
    private RelativeLayout mLayoutMerchantInfo;
    @Inject(R.id.username)
    private TextView mTextViewName;
    @Inject(R.id.uid)
    private TextView mTextViewuid;

    @Override
    protected void onSetContentView() {
        setContentView(R.layout.fragment_account);
    }

    @Override
    protected void initViews() {
        mLayoutBack.setVisibility(View.GONE);
        mTextViewTitle.setText("账户");
    }

    @Override
    protected void afterOnCreate(Bundle savedInstanceState) {
        mTextViewName.setText(String.valueOf(App.getApp().getUserInfo().getData().getMobile()));
        mTextViewuid.setText(String.valueOf(App.getApp().getUserInfo().getData().getId()));
    }

    @Override
    protected void onSetListener() {
        mLayoutMobileChange.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                startActivity(new Intent(getActivity(), ChangeMobileActivity.class));
            }
        });
        mLayoutPasswordChange.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent(getActivity(), RegistAndForgetActivity.class);
                intent.putExtra(Constant.LOGIN_MODE, Constant.MODE_FORGET);
//                startActivity(intent);
                startActivityForResult(intent, 0);
            }
        });
        mLayoutMerchantInfo.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                startActivity(new Intent(getActivity(), AccountInfoActivity.class));
            }
        });
    }
}
